const {baseController} = require('../../baseController')
const serviceEnter = require('../../../service/serviceEnter')
const {result} = require('../../../util/result/result')



class user_location_profession_controller extends  baseController{
    static sigleIns = new user_location_profession_controller()

    static getSigleIns =()=>{
        if(this.sigleIns){
            return this.sigleIns
        }else{
            return new user_location_profession_controller()
        }
    }

    constructor(){
        super(serviceEnter.locationProfessionService.getIns())
    }


    // 会更新添加到数组
    async findByObjAndUpdateAddtoset (req,res){     
        let options={"new":true,"upsert":true}
        let data
        try {
            data =  await  serviceEnter.locationProfessionService.getIns().findByObjAndUpdateArray(req.body.obj,req.body.update_content,options)
        } catch (error) {
            console.log(error,33);
            res.send(result(false,error))
            return
        }
        
        if(data&&data!=undefined){
            res.send(result(true,data))
         }else{
            res.send(result(false))
         }
       }

    async findByObjAndUpdate (req,res){     
        let options={"new":true,"upsert":true}
    
        let data
        try {
            data =  await  serviceEnter.locationProfessionService.getIns().findByObjAndUpdate(req.body.obj,req.body.update_content,options)
        } catch (error) {
           
            res.send(result(false,error))
            return
        }
        
        if(data&&data!=undefined){
            res.send(result(true,data))
         }else{
            res.send(result(false))
         }
       }



}

module.exports={
    user_location_profession_controller
}